from api.ihrmEmpManageApi import EmpManageApi
from common.assertTools import common_assert
from common.dbTools import DBTools
from common.getHeader import get_header
from config import EMP_ID


class TestQueryEmp(object):
    def setup_class(self):
        #创建实例
        self.emp = EmpManageApi()
        # 获取请求头
        self.req_header = get_header()
    def setup(self):
        # 添加员工id
        DBTools.db_iud(f"insert into bs_user(id,mobile,username)values({EMP_ID},'18900777213','小孙');")

    def teardown(self):
        # 删除添加的id
        DBTools.db_iud(f"delete from bs_user where id = '{EMP_ID}';")

    def test01_query_success(self):
        """查询成功"""

        resp = self.emp.query_emp(EMP_ID, self.req_header)
        print("查询员工成功", resp.json())
        common_assert(resp, 200, True, 10000, "操作成功")

    def test02_emp_id_not_exists(self):
        """查询员工id不存在"""
        resp = self.emp.query_emp("75386",self.req_header)
        print("查询员工id不存在",resp.json())
        common_assert(resp,200,False,20005,"查询员工失败")




